home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Codigo / Imágenes y mapas de bits / CenterPixelSizeImage / CenterPixelSizeImage.cs next >
Encoding:
Text File  |  2002-05-06  |  728 b   |  29 lines

  1. //---------------------------------------------------
  2. // CenterPixelSizeImage.cs ⌐ 2001 by Charles Petzold
  3. //---------------------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7.  
  8. class CenterPixelSizeImage: PrintableForm
  9. {
  10.     Image image;
  11.  
  12.     public new static void Main()
  13.     {
  14.         Application.Run(new CenterPixelSizeImage());
  15.     }
  16.     public CenterPixelSizeImage()
  17.     {
  18.         Text = "Centrar imagen (en pφxeles)";
  19.  
  20.         image = Image.FromFile("..\\..\\..\\Apollo11FullColor.jpg");
  21.     }
  22.     protected override void DoPage(Graphics grfx, Color clr, int cx, int cy)
  23.     {
  24.         grfx.DrawImage(image, (cx - image.Width)  / 2,
  25.             (cy - image.Height) / 2,
  26.             image.Width, image.Height);
  27.     }
  28. }
  29.